var status = -1;
var selectionLog = [];

function start() {
    action(1, 0, 0)
}

function action(f, c, b) {
    if (status == 0 && f == 0) {
        im.dispose();
        return
    }(f == 1) ? status++ : status--;
    selectionLog[status] = b;
    var a = -1;
    if (status <= a++) {
        im.dispose()
    } else {
        if (status === a++) {
            var d = [4001832, 4001839, 2048703, 2049710];
            var e = [100, 10, 1, 1];
            var a = im.rand(0, d.length - 1);
            im.gainItem(d[a], e[a]);
            im.removeItem(im.getItemId());
            im.dispose()
        }
    }
};